  const webpackMerge = require('webpack-merge');
    const webpack = require('webpack');
    const ChunkManifestPlugin = require('chunk-manifest-webpack-plugin');
    const ExtractTextPlugin = require('extract-text-webpack-plugin');
    const WebpackMd5Hash = require('webpack-md5-hash');

    const baseConfig = require('./webpack/base.js');
    const config = require('./webpack/config');
    const defPath = config.defPath;
    const APP_PATH = defPath.APP_PATH;

    module.exports = webpackMerge(baseConfig, {
        entry: {
            app: defPath.ENTRY_PATH,
            vendor: config.vendor
        },
        output: {
            path: defPath.BUILD_PATH,
            // 所有输出文件的目标路径
            filename: 'js/bundle.js?[chunkhash]',
            publicPath: 'http://wanwang',   // 修改成发布的地址
            chunkFilename: 'chunk.js?[chunkhash]'
        },
        module: {
            rules: [
               {    
                    test: /\.js$/,    
                    exclude: /node_modules/,     
                    use: {
                    loader: 'babel-loader',
                    query: {
                        presets: ["es2015"]
                        }
                    }    
                },
                {
                    test: /\.(less|css)$/,
                    include: APP_PATH,
                    use: ExtractTextPlugin.extract({    // css 单独打包，（2.x 改变很大）
                        fallback: 'style-loader',
                        use: 'css-loader!less-loader' + config.sassLoaderConfig
                    })
                }, {
                    test: /\.(eot|woff|woff2|ttf|svg|png|jpe?g|gif|mp4|webm)(\?\S*)?$/,
                    include: APP_PATH,
                    loader: 'url-loader?limit=8192&name=imgs/[name].[ext]?[hash]'
                }
            ]
        },
        plugins: [
            new WebpackMd5Hash(),   // 取代标准webpack chunkhash
            new webpack.DefinePlugin({
                'process.env.NODE_ENV': JSON.stringify('production')
            }),

            // js 压缩
            // new webpack.optimize.UglifyJsPlugin(config.uglifyJsConfig),
            new webpack.optimize.CommonsChunkPlugin({
                names: [
                    'vendor', 'manifest'
                ],
                filename: 'js/[name].js?[chunkhash]',
                minChunks: Infinity
            }),
            new ChunkManifestPlugin({
                filename: 'chunk-manifest.json',
                manifestVariable: 'webpackManifest'
            }),
            // css 抽取
            new ExtractTextPlugin({
                filename: 'css/styles.css?[contenthash]',
                disable: false,
                allChunks: true
            })
        ]
    })